﻿Imports System.Data.Linq
Public Class frmChungTuOption
    Dim ctrlDanhMuc As New CDanhMucController
    Dim curBangKe As tblBangKeChungTu = Nothing
    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub btPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btPrint.Click
        Dim dt As New DataTable()
        XL_DULIEU.GanCauLenhKetNoi(Global.QLyNganSach.My.MySettings.Default.QLyNganSachConnectionString)
        XL_DULIEU.LayDuLieuRaBang("select NgayChungTu, SoChungTu, NoiDung, SoTien from tblChungTu ct where ct.ID_BangKeChungTu =" & curBangKe.ID_BangKeChungTu.ToString, dt)
        dt.TableName = "ChungTuInfo"
        Dim ds As New DataSet
        ds.Tables.Add(dt)
        Dim tongTien As Double = 0
        For Each r As DataRow In dt.Rows
            tongTien += Double.Parse(r("SoTien").ToString())
        Next
        Dim tienChu As String = CUtilities.NumToStringVietNam(tongTien)
        Dim rpt As New rptChungTu
        rpt.SetDataSource(ds)
        rpt.SetParameterValue("khoan", "Khoản: " & curBangKe.tblDanhMuc.Ma)
        rpt.SetParameterValue("noiDungNganSach", "Kinh phí: " & curBangKe.tblDanhMuc.NoiDung)
        rpt.SetParameterValue("tienChu", tienChu)
        rpt.SetParameterValue("thoiGian", "Tháng " & curBangKe.ThangQuyetToan & "/" & curBangKe.NamQuyetToan)
        rpt.SetParameterValue("nguoiChiTieu", txtNguoiPhuTrach.Text)
        rpt.SetParameterValue("truongPhong", txtTruongPhong.Text)
        rpt.SetParameterValue("KeToan", txtKeToan.Text)
        rpt.SetParameterValue("ThuTruong", txtThuTruong.Text)
        rpt.SetParameterValue("tenPhongBan", curBangKe.tblDonVi.Ten)
        Dim frm As New frmView(rpt)
        frm.ShowDialog()
        Me.Close()
    End Sub

    Public Sub New(ByVal _objBangKe As tblBangKeChungTu)

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        curBangKe = _objBangKe
    End Sub

    Private Sub frmChungTuOption_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtThuTruong.Focus()
    End Sub
End Class